package com.tn.shirojwt.dao;

import com.tn.shirojwt.bean.Permission;
import com.tn.shirojwt.bean.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @create 2020-03-16  16:27
 **/
public interface PermissionDao extends JpaRepository<Permission, Long>, JpaSpecificationExecutor<Permission> {
//    /**
//      * 根据roles获得用户角色默认的权限
//     */
//    @Query(" select e from Permission e where e.roles in (?1) ORDER BY e.createTime DESC ")
//    String getRolePermission(List<String> roles );

    /**
     * 根据 roleId 获得用户的权限
     */
//    @Query(" select e.state from Permission e where e.roles =?1 ORDER BY e.createTime DESC ")
    List<Permission> findByRoles(List<String> roles);
}
